<template>
  <div>
    <el-form :inline="true" align="center">
      <el-form-item label="科室名称">
        <el-input
          type="text"
          placeholder="请输入科室名称"
          v-model="hospitalDept.deptname"
        /> </el-form-item
      ><br />
      <el-button type="primary" @click="addHospitalDept">提交</el-button>
      <el-button type="primary">
        <router-link to="/hospital/hospitalDeptList"
          >取消</router-link
        ></el-button
      >
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      hospitalDept: {
        deptname: "",
      },
      url: "http://localhost:8080/jiapei/hos-dept/hospitalDepts",
    };
  },
  methods: {
    addHospitalDept() {
      this.$axios({
        url: this.url,
        method: "POST",
        data: this.hospitalDept,
      }).then((res) => {
        if (res.data.code == 200) {
          this.$message({ message: res.data.message, type: "success" });
          this.$router.push("/hospital/hospitalDeptList");
        } else if (res.data.code == 211) {
          this.$message({ message: res.data.message, type: "warning" });
          this.$router.push("/hospital/hospitalDeptList");
        }
      });
    },
  },
};
</script>

<style>
</style>